import $http from 'servers/http';
import { Result } from 'seats/schema/Result';
import { Calldatainfo, Callcount } from 'seats/schema/HomePage';
import { JSONObject } from '../../schema/common';
/* 首页统计
---------------------------------------------------------------- */

/** 外呼数据*/
export const calldatainfo = (data: any): Promise<Result<Calldatainfo>> => {
  return $http.get({
    url: '/seats/statistics/calldatainfo',
    data: data,
  });
};
/** 接通/人工介入量统计（查7日）*/
export const callcount = (): Promise<Result<Callcount[]>> => {
  return $http.get({
    url: '/seats/statistics/callcount',
  });
};
/** 话术跳出率*/
export const flownodejumpout = (data: JSONObject): Promise<Result<JSONObject>> => {
  return $http.get({
    url: '/icms/taskmanage/datastatistics/flownodejumpout',
    data,
  });
};

/** 热门问题*/
export const hotspotquestion = (data: JSONObject): Promise<Result<JSONObject>> => {
  return $http.get({
    url: '/icms/taskmanage/datastatistics/hotspotquestion',
    data,
  });
};
/** 数据统计*/
export const datastatistics = (data: JSONObject): Promise<Result<JSONObject>> => {
  return $http.get({
    url: '/icms/taskmanage/datastatistics/date',
    data,
  });
};

/** 呼叫结果统计*/
export const callresult = (data: JSONObject): Promise<Result<JSONObject>> => {
  return $http.get({
    url: '/icms/taskmanage/datastatistics/callresult',
    data,
  });
};
/** 查询任务列表-无数据权限*/
export const taskscanceldatapermission = (data: JSONObject): Promise<Result<JSONObject>> => {
  // get请求，需要转换操作类型数组
  let flowTypeStr = '';
  data.flowType?.forEach((type: any) => {
    flowTypeStr += `flowType=${type}&`;
  });
  delete data.flowType;
  return $http.get({
    url: `/icms/taskmanage/tasks/canceldatapermission?${flowTypeStr}`,
    data,
  });
};
/** 分页查询机器人列表-无数据权限*/
export const robotscanceldatapermission = (data: JSONObject): Promise<Result<JSONObject>> => {
  return $http.get({
    url: '/robotmanage/robots/canceldatapermission',
    data,
  });
};
